//------------------------------------------------------------------------------
#include <QTextStream>
#include <QMessageBox>
#include <QDir>
#include "CHelp.h"
//------------------------------------------------------------------------------
CHelp *CHelp::_instance=0;
//------------------------------------------------------------------------------
CHelp * CHelp::getInstance(void) {		
	if(_instance == 0) {	
		_instance=new CHelp();
	}
	
	return _instance;
}
//------------------------------------------------------------------------------
void CHelp::startHelp(QString cmd) {
	if(process->state() == QProcess::NotRunning) {
		QStringList args;
		QString path=QDir::toNativeSeparators(_docPath+QString("/coMexpert.qhc"));
		
		args << QString("-collectionFile") << path;
		args << QString("-enableRemoteControl");
		
		process->start(QString("assistant"), args);
		
		if(!process->waitForStarted()) {
			return;
		}
	}
	
	if(cmd != "") {
		QTextStream str(process);
		str << cmd << endl;
	}
}
//------------------------------------------------------------------------------
void CHelp::setDocPath(QString path) {
#ifndef WIN32
	path.replace(" ", "\\ ");
#endif
	_docPath=path;
}
//------------------------------------------------------------------------------